/**
 * @FileName Client.java
 * @Package com.designMode.factoryMethod
 * -------------------------------------
 * @function Please write description of function
 * @Date 2016-1-5 下午2:40:24
 * -------------------------------------
 * Copyright (c) 2016,顾博君 All Rights Reserved.
 */
package com.designMode.factoryMethod;

/**
 * @author 顾博君
 * @ClassName Client
 * @Date 2016-1-5 下午2:40:24
 * @Function 场景类
 */

public class Client {
    public static void main(String args[]) {
        // 简单工厂模式
        SimpleFactory simpleFactory = new SimpleFactory();
        Product simpleProduct1 = simpleFactory.createProduct(1);
        Product simpleProduct2 = simpleFactory.createProduct(2);
        simpleProduct1.method2();
        simpleProduct2.method2();
        // 工厂方法模式
        AbsFactory factory1 = new ConcreteFactory1();
        AbsFactory factory2 = new ConcreteFactory2();
        Product normalProduct1 = factory1.createProduct();
        Product normalProduct2 = factory2.createProduct();
        normalProduct1.method2();
        normalProduct2.method2();
        // 优化工厂方法模式，新建工厂类
        Factory creator = new ConcreteFactory();
        // 生产产品1
        Product product1 = creator.createProduct(ConcreteProduct1.class);
        // 生产产品2
        Product product2 = creator.createProduct(ConcreteProduct2.class);
        // 执行产品方法
        product1.method1();
        product1.method2();
        product2.method2();
    }
}
